package com.hyxt.DTO.process;

import com.hyxt.DTO.CommonMessage;
import com.hyxt.DTO.CommonMessageHeader;
import com.hyxt.superviseservice.CommonMessageBody;
import com.hyxt.superviseservice.IMessageBody;
import com.hyxt.superviseservice.messageBody.T809_0x1200;
import com.hyxt.utils.BytesUtil;
import com.hyxt.utils.T809_Process;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.UnsupportedEncodingException;

/**
 * @Project: CNPC_VMS
 * @Title: T809_0x1200
 * @Description: 主链路动态信息交换消息
 * @author: denghl
 * @date: 2014年4月24日 下午5:11:36
 * @company: Beijing Huayou Information andCommunication Technology Co.,Ltd
 * @Copyright: Copyright (c) 2014
 * @version V2.0
 */
public class T809_0x1200_Process<B extends IMessageBody> extends T809_Process<B> {

	static Log log = LogFactory.getLog(T809_0x1200_Process.class);

	@Override
	protected CommonMessageBody getBody(CommonMessageHeader header, byte[] data) {
		//
		T809_0x1200 body = new T809_0x1200();
		// 车牌号
		byte[] VEHICLE_NO = BytesUtil.cutBytes(0, 21, data);
		// 车牌颜色
		byte VEHICLE_COLOR = BytesUtil.getByte(21, data);
		// 数据类型
		byte[] DATA_TYPE = BytesUtil.getWord(22, data);
		// 数据长度
		byte[] DATA_LENGTH = BytesUtil.cutBytes(24, 4, data);
		// 数据部分
		byte[] DATA = BytesUtil.cutBytes(28, data.length - 28, data);
		try {
			body.setVEHICLE_NO(new String(VEHICLE_NO, "US-ASCII"));
		} catch (UnsupportedEncodingException e) {
			log.warn("", e);
		}
		// 设置属性
		body.setVEHICLE_COLOR(VEHICLE_COLOR);
		body.setDATA_TYPE(BytesUtil.parseBytesToShort(DATA_TYPE));
		body.setDATA_LENGTH(BytesUtil.parseBytesToInt(DATA_LENGTH));
		body.setDATA(DATA);
		return body;
	}

	/* (non-Javadoc)
	 * @see cn.com.cnpc.vms.protocols.tcp.T809.T809_Process#packData(cn.com.cnpc.vms.common.protocols.common.CommonMessage)
	 */
	@Override
	protected byte[] packData(CommonMessage<B> message) {
		// TODO Auto-generated method stub
		return null;
	}

}
